<template>
  <div>
    <div class="title">金华市工伤智防联控</div>
    <div class="datetime">
      <div id="showTime2" class="time"/>
      <div class="date">
        <div id="showWeek2" class="week"/>
        <div id="showDate2"/>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  name: "Part_top",
  created() {
    const timer = setTimeout(time, 1000);//開始运行
    function time() {
      clearTimeout(timer);//清除定时器
      const date = new Date();
      const year = date.getFullYear();
      const month = (date.getMonth() + 1).toString().padStart(2, '0');
      const day = date.getDate().toString().padStart(2, '0');
      const week = date.getDay();
      const hours = date.getHours().toString().padStart(2, '0');
      const minutes = date.getMinutes().toString().padStart(2, '0');
      const seconds = date.getSeconds().toString().padStart(2, '0');
      document.getElementById("showTime2").innerHTML = hours + ":" + minutes + ":" + seconds;
      document.getElementById("showWeek2").innerHTML = "星期" + "日一二三四五六".charAt(week);
      document.getElementById("showDate2").innerHTML = year + "." + month + "." + day;
      setTimeout(time, 1000); //设定定时器，循环运行
    }
  }
}
</script>

<style scoped>
.title {
  display: inline-block;
  float: left;
  margin-top: 1rem;
  margin-left: 42%;
  color: #D9EBFA;
  font-size: 2.6rem;
  font-weight: 600;
}

.datetime {
  display: inline-block;
  float: right;
  width: 11%;
  height: 4%;
  margin-right: 7%;
  margin-top: 1.4rem;
  color: #D9EBFA;
}

.time {
  display: inline-block;
  float: left;
  margin-top: 5%;
  font-family: LCD2;
  font-size: 1.8rem;
}

.date {
  display: inline-block;
  float: right;
  margin-top: 2%;
  font-size: .9rem;
}

.week {
  float: right;
}
</style>
